// app.js
let $https=require('/utils/request')
wx.$https=$https
wx.baseURL=$https.baseURL
wx.get=$https.get
wx.put = $https.put
wx.post = $https.post
wx.delete = $https.delete

App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        console.log('I am wx.login',res)
        wx.get('http://localhost:3000/wx/login?code=' + res.code).then(res =>{
          console.log('打印',res)
          wx.userInfo = res.userInfo
          wx.token = res.token
        })
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  globalData: {
    userInfo: null
  }
})
